/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

/**
 *
 * @author USER
 */
public class InfoPanel extends JPanel {

	private JTabbedPane mainTabbedPanel;
	private JPanel generalInfoPnl1, fileInfoPnl1, peersInfoPnl1;
	private JLabel lblTxtFileName, lblTxtFilePath, lblTxtFileSize,
			lblTxtUploadSpeed, lblTxtUploaded, lblTxtDownloadSpeed, lblTxtDownloaded,
			lblTxtEstTime, lblTxtUDRatio;
	private JTextArea txtFileDesc;
	
	public InfoPanel() {
		this.setLayout( new BorderLayout() );
		JPanel generalInfoPnl = new JPanel();
		JPanel fileInfoPnl = new JPanel();
		JPanel peersInfoPnl = new JPanel();

		generalInfoPnl1 = new JPanel( new BorderLayout() );
		fileInfoPnl1 = new JPanel( new BorderLayout() );
		peersInfoPnl1 = new JPanel( new BorderLayout() );

		mainTabbedPanel = new JTabbedPane();
		mainTabbedPanel.addTab( "General info", generalInfoPnl1 );
//		mainTabbedPanel.addTab( "File pieces info", fileInfoPnl1 );
//		mainTabbedPanel.addTab( "Peers info", peersInfoPnl1 );

		// general info
		JPanel generalTmpPanel = new JPanel( new FlowLayout( FlowLayout.LEFT ) );
		generalInfoPnl1.add( generalTmpPanel, BorderLayout.PAGE_START );
		generalTmpPanel.add( generalInfoPnl );

		generalInfoPnl.setLayout( new GridBagLayout() );
		generalInfoPnl.setBorder( new EmptyBorder( 8, 8, 8, 8 ) );
		GridBagConstraints c = new GridBagConstraints();
		c.ipadx = 6;
		c.ipady = 6;
		c.weightx = 0.0;
		c.anchor = GridBagConstraints.FIRST_LINE_START;

		JLabel lblFile = new JLabel( "File name " );
		lblFile.setHorizontalTextPosition( JLabel.LEFT );
		lblFile.setMinimumSize( new Dimension( 150, 2 ) );
		c.gridx = 0;
		c.gridy = 0;
		generalInfoPnl.add( lblFile, c );

		lblTxtFileName = new JLabel( "The file name [dot] ext" );
		c.gridx = 1;
		c.gridy = 0;
		c.fill = GridBagConstraints.HORIZONTAL;
		c.gridwidth = 3;
		generalInfoPnl.add( lblTxtFileName, c );

		JLabel lblFilePath = new JLabel( "Save to" );
		c.gridx = 0;
		c.gridy = 1;
		c.gridwidth = 1;
		c.fill = GridBagConstraints.NONE;
		generalInfoPnl.add( lblFilePath, c );

		lblTxtFilePath = new JLabel( "/home/trunghieu/PROJECT/some where in the world" );
		c.gridx = 1;
		c.gridy = 1;
		c.gridwidth = 3;
		c.fill = GridBagConstraints.HORIZONTAL;
		generalInfoPnl.add( lblTxtFilePath, c );

		JLabel lblFileSize = new JLabel( "File size" );
		c.gridx = 0;
		c.gridy = 2;
		c.gridwidth = 1;
		c.fill = GridBagConstraints.NONE;
		generalInfoPnl.add( lblFileSize, c );

		lblTxtFileSize = new JLabel( "235MB" );
		c.gridx = 1;
		c.gridy = 2;
		generalInfoPnl.add( lblTxtFileSize, c );
		
		JLabel lblFileDesc = new JLabel( "Description");
		c.gridx = 0;
		c.gridy = 3;
		generalInfoPnl.add( lblFileDesc, c);
		
		txtFileDesc = new JTextArea( "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
		txtFileDesc.setColumns( 80);
		txtFileDesc.setRows( 6);
		txtFileDesc.setWrapStyleWord( true );
		txtFileDesc.setLineWrap( true );
		txtFileDesc.setBorder( null );
		JScrollPane fileDescPnl = new JScrollPane( txtFileDesc);
		c.gridx = 1;
		c.gridy = 3;
		c.gridwidth = 3;
		generalInfoPnl.add( fileDescPnl, c);

		JLabel lblDownloaded = new JLabel( "Downloaded" );
		c.gridx = 0;
		c.gridy = 4;
		c.gridwidth = 1;
		generalInfoPnl.add( lblDownloaded, c );

		lblTxtDownloaded = new JLabel( "0KB" );
		c.gridx = 1;
		c.gridy = 4;
		generalInfoPnl.add( lblTxtDownloaded, c );

		JLabel lblDownSpeed = new JLabel( "Download speed" );
		c.gridx = 2;
		c.gridy = 4;
		generalInfoPnl.add( lblDownSpeed, c );

		lblTxtDownloadSpeed = new JLabel( "10.5MB/s" );
		c.gridx = 3;
		c.gridy = 4;
		generalInfoPnl.add( lblTxtDownloadSpeed, c );

		JLabel lblUploaded = new JLabel( "Uploaded" );
		c.gridx = 0;
		c.gridy = 5;
		generalInfoPnl.add( lblUploaded, c );

		lblTxtUploaded = new JLabel( "0KB" );
		c.gridx = 1;
		c.gridy = 5;
		generalInfoPnl.add( lblTxtUploaded, c );

		JLabel lblUploadSpeed = new JLabel( "Upload speed" );
		c.gridx = 2;
		c.gridy = 5;
		generalInfoPnl.add( lblUploadSpeed, c );

		lblTxtUploadSpeed = new JLabel( "10.5MB/s" );
		c.gridx = 3;
		c.gridy = 5;
		generalInfoPnl.add( lblTxtUploadSpeed, c );


		JLabel lblEstTime = new JLabel( "Estimated time" );
		c.gridx = 0;
		c.gridy = 6;
		generalInfoPnl.add( lblEstTime, c );

		lblTxtEstTime = new JLabel( "1234s" );
		c.gridx = 1;
		c.gridy = 6;
		generalInfoPnl.add( lblTxtEstTime, c );

		JLabel lblUpDownRatio = new JLabel( "Up/Down ratio " );
		c.gridx = 0;
		c.gridy = 7;
		generalInfoPnl.add( lblUpDownRatio, c );

		lblTxtUDRatio = new JLabel( "1.345" );
		c.gridx = 1;
		c.gridy = 7;
		generalInfoPnl.add( lblTxtUDRatio, c );

		// end general info

		this.add( mainTabbedPanel );

		// general panel

		// end general panel
	}
}
